<?php declare(strict_types=1);
namespace app\controller;
use app\exception\Failure;
use app\exception\RequestMethodInvalidate;
use app\exception\Success;
use app\facade\logic\AuthGroup as FaAuthGroupLogic;

class Group extends AuthBase{

    /**
     * del
     * @Route("/group/del")
     */
    public function del(){
        if($this->request->isPost()){
            $result = FaAuthGroupLogic::del();
            if($result){
                throw new Success();
            }else{
                throw new Failure();
            }
        }
        throw new RequestMethodInvalidate();
    }

    public function haveAuth(){
        if($this->request->isPost()){
            $result = FaAuthGroupLogic::haveAuth();
            throw new Success($result);
        }
        throw new RequestMethodInvalidate();
    }

    /**
     * update
     * @Route("/group/update")
     */
    public function update(){
        if($this->request->isPost()){
            $result = FaAuthGroupLogic::update();
            if($result){
                throw new Success();
            }else{
                throw new Failure();
            }
        }
    }

    /**
     * create
     * @Route("/group/create")
     */
    public function create(){
        if($this->request->isPost()){
            $result = FaAuthGroupLogic::create();
            if($result){
                throw new Success();
            }else{
                throw new Failure();
            }
        }
    }

    /**
     * create
     * @Route("/group/list")
     */
    public function list(){
        if($this->request->isPost()){
            $list = FaAuthGroupLogic::getAuthGroupList();
            throw new Success($list);
        }
        throw new RequestMethodInvalidate();
    }
}
 
